import java.util.Scanner;

public class Demo25 {
    private static Object locker=new Object();
public static void main(String[] args) throws InterruptedException {
    Thread t1=new Thread(()->{
        System.out.println("t1wait之前");
        synchronized(locker){
            try {
                locker.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("t1wait之后");
    });
        Thread t2=new Thread(()->{
        System.out.println("t2wait之前");
        synchronized(locker){
            try {
                locker.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("t2wait之后");
    });
        Thread t3=new Thread(()->{
        System.out.println("t3wait之前");
        synchronized(locker){
            try {
                locker.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("t3wait之后");
    });
     Thread t4=new Thread(()->{
    Scanner scanner = new Scanner(System.in);
     System.out.println("请输入任意内容，唤醒线程");
     scanner.next();
     synchronized(locker){
        locker.notifyAll();     
     }
    });
     t1.start();
     t2.start();
     t3.start();
     t4.start();
     t1.join();
     t2.join();
     t3.join();
     t4.join();
}
}
